package com.kmist.jianghu;

import android.app.Activity;
import android.content.Context;

import TOOL.SaveTool;

public class Player {

    public static SaveTool saveTool;
    private static Context mContext;

    public Player(Context context){
        mContext = context;
        saveTool = new SaveTool(mContext, "JiangHu");
    }

    public Player(Context context, String name, String sex){
        mContext = context;
        saveTool = new SaveTool(mContext, "JiangHu");
        if(saveTool.getString("name","").equals("")){
            MainActivity.Alarm("Null Data");
            savePlayer();
        }else{
            loadPlayer();
        }
    }

    public void createPlayer(String name, String sex){
        mName = name;
        mSex = mSex;
        mHp = 1000;
        mAttach = 100;
        mDefence = 5;
        mSpeed = 100;
        mLevel = 0;
        mEvolution = 0;
        mJinbi = 0;
        savePlayer();
    }

    public void savePlayer()
    {
        saveTool.putString("name", mName);
        saveTool.putString("sex", mSex);
        saveTool.putInt("hp", mHp);
        saveTool.putInt("Attach", mAttach);
        saveTool.putInt("Defence", mDefence);
        saveTool.putInt("Speed", mSpeed);
        saveTool.putInt("Level", mLevel);
        saveTool.putInt("Evolution", mEvolution);
        saveTool.putInt("Jinbi", mJinbi);
    }

    public void loadPlayer(){
        mName = saveTool.getString("name", "");
        mSex = saveTool.getString("sex", "");
        mHp = saveTool.getInt("hp", 0);
        mCurHp = mHp;
        mAttach = saveTool.getInt("Attach", 0);
        mDefence = saveTool.getInt("Defence", 0);
        mSpeed = saveTool.getInt("Speed", 0);
        mLevel = saveTool.getInt("Level", 0);
        mEvolution = saveTool.getInt("Evolution", 0);
        mJinbi = saveTool.getInt("Jinbi", 100);
    }

    public String getmName() {
        return mName;
    }

    public void setmName(String mName) {
        this.mName = mName;
    }

    public String getmSex() {
        return mSex;
    }

    public void setmSex(String mSex) {
        this.mSex = mSex;
    }

    public int getmHp() {
        return mHp;
    }

    public void setmHp(int mHp) {
        this.mHp = mHp;
    }

    public int getmAttach() {
        return mAttach;
    }

    public void setmAttach(int mAttach) {
        this.mAttach = mAttach;
    }

    public int getmDefence() {
        return mDefence;
    }

    public void setmDefence(int mDefence) {
        this.mDefence = mDefence;
    }

    public int getmLevel() {
        return mLevel;
    }

    public void setmLevel(int mLevel) {
        this.mLevel = mLevel;
    }

    public int getmEvolution() {
        return mEvolution;
    }

    public void setmEvolution(int mEvolution) {
        this.mEvolution = mEvolution;
    }

    public int getmNextEvolution() {
        return mNextEvolution;
    }

    public void setmNextEvolution(int mNextEvolution) {
        this.mNextEvolution = mNextEvolution;
    }

    private String mName;
    private String mSex;
    private int mHp;
    private int mAttach;
    private int mDefence;
    private int mSpeed;
    private int mLevel;
    private int mEvolution;
    private int mNextEvolution;
    private int mCurHp;

    public int getmJinbi() {
        return mJinbi;
    }

    public void setmJinbi(int mJinbi) {
        this.mJinbi = mJinbi;
    }

    private int mJinbi;

    public int getmSpeed() {
        return mSpeed;
    }

    public void setmSpeed(int mSpeed) {
        this.mSpeed = mSpeed;
    }

    public int getmCurHp() {
        return mCurHp;
    }

    public void setmCurHp(int mCurHp) {
        this.mCurHp = mCurHp;
    }




    public void die() {
        //MainActivity.Alarm("你被怪物杀死了");
    }
}
